<template>
	<section>

		<!--列表-->
		<el-table :data="listData" highlight-current-row v-loading="listLoading" @selection-change="selsChange" style="width: 100%;">
			<!--展开列-->
			<el-table-column type="expand">
				<template slot-scope="scope">
					<el-column v-for="(item,i) in scope.row.children" :key="item.id">
						<el-tag @close="removePermissionById(scope.row,item.id)" type="warning">{{item.name}}</el-tag>
					</el-column>
				</template>
			</el-table-column>

			<el-table-column type="selection" width="55">
			</el-table-column>
			<el-table-column type="index" width='500'>
			</el-table-column>
			<el-table-column prop="name" label="菜单名称"  width="250" sortable>
			</el-table-column>
		</el-table>

	</section>
</template>

<script>
    //import util from '../../common/js/util'
    //import NProgress from 'nprogress'
    //import { getUserListPage, removeUser, batchRemoveUser, editUser, addUser } from '../../api/api';

    export default {
        data() {
            return {
                filters: {
                    name: ''
                },
                listData: [],
                total: 0,
                keyword:'',
                pageSize: 10,
                currentPage:1,
                listLoading: false,
                sels: [],//列表选中列
            }
        },
        methods: {
            handleCurrentChange(val) {
                this.currentPage=val;
                this.getListData();
            },
            //获取用户列表
            getListData() {
                let para = {
                    currentPage: this.currentPage,
                    pageSize:this.pageSize,
                    keyword: this.filters.name
                };
                this.listLoading = true;
                this.$http.get('/menu/findMenu',para).then(res=>{
                    let ajaxResult =  res.data
                    if (ajaxResult.success){
                        this.listData = ajaxResult.data;
                        this.total = ajaxResult.data.total
                    }else {
                        this.$message({
                            message: '加载失败',
                            type: 'error'
                        });
                    }
                    this.listLoading = false;
                }).catch(error=>{
                    this.listLoading = false;
                    this.$message({
                        message: '加载失败',
                        type: 'error'
                    });
                })
            },
            selsChange: function (sels) {
                this.sels = sels;
            },
        },
        mounted() {
            this.getListData();
        }
    }

</script>

<style scoped>

</style>